package com.larsgard.gedviewer.client.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.larsgard.gedviewer.shared.ajax.SearchResult;

public class SearchResultEvent extends GwtEvent<SearchResultEvent.SearchResultHandler> {

    public interface SearchResultHandler extends EventHandler {
	public void onResultLoaded(SearchResultEvent p);
    }

    public static final Type<SearchResultHandler> TYPE = new Type<SearchResultHandler>();

    private SearchResult searchResult;

    public SearchResultEvent(SearchResult result) {
	this.searchResult = result;
    }

    public void setSearchResult(SearchResult searchResult) {
	this.searchResult = searchResult;
    }

    public SearchResult getSearchResult() {
	return searchResult;
    }

    @Override
    protected void dispatch(SearchResultHandler searchResultHandler) {
	searchResultHandler.onResultLoaded(this);
    }

    @Override
    public Type<SearchResultHandler> getAssociatedType() {
	return TYPE;
    }

}
